﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using FOBVT.Web.MainClass;
using iTextSharp.text;
using System.IO;
using iTextSharp.text.pdf;

namespace FOBVT.Web.FOBVT2011.UserControl
{
	public partial class CustomerStatusListControl : System.Web.UI.UserControl
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!IsPostBack)
			{
				bindgrid();
			}
		}

		//绑定数据
		private void bindgrid()
		{
			int pageindex = dgCustomsers.CurrentPageIndex + 1;
			MainClass.DBClass DBClassTmp = new MainClass.DBClass();
			string strSQL = "";
			if (pageindex == 1)
                strSQL = "SELECT Format(CreateTime, 'yyyy-mm-dd') as CreateTime,Sum(iif(StatusID=1,1,0) ) as aaaa,Sum(iif(StatusID=2,1,0) ) as bbbb,Sum(iif(StatusID=3,1,0) ) as cccc,Sum(iif(StatusID=4,1,0) ) as dddd,Sum(iif(StatusID=5,1,0) ) as eeee FROM CustomerInfo Group by  Format(CreateTime, 'yyyy-mm-dd') order by  Format(CreateTime, 'yyyy-mm-dd') Desc";
			else
				strSQL = "SELECT top 50 * FROM CustomerInfo where CustomerID not in(select top " + ((pageindex - 1) * 50).ToString() + " CustomerID from CustomerInfo order by CustomerID desc)  order by CustomerID desc";
			System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("..\\..\\DB\\FOBVTweb.mdb"));
			DataSet ds = DBClassTmp.GetDataSet(strSQL, Conn);

			dgCustomsers.DataSource = ds;
			dgCustomsers.DataBind();
		}

	}
}